1. Field of the Invention
The present invention relates to a method for generating an image for display on a graphic computer, entertainment device, video device, etc., and more particularly to a method and apparatus for generating, by shading, an image having a stereoscopic or three-dimensional vision.
2. Description of Related Art
For generating a game displayed on a graphic computer, computer-game device, video device or the like, a method called xe2x80x9ctexture mappingxe2x80x9d is known by which an image is generated by deforming a texture and pasting it on a three-dimensionally defined object.
FIG. 1 shows the texture mapping method. As shown, a rectangular texture 101 is pasted on a spherical region defined as a three-dimensional object to generate an image of a sphere 102.
Although the object image thus generated is defined three-dimensionally, its stereoscopic vision is poor since the image is only a monotonous figure displayed two-dimensionally. For easier recognition of the shape and spatial position of a object when displayed, it has been proposed to shade an object by irradiating to the object a light from a virtual source, thereby allowing the object to have a three-dimensional vision.
For such a shading, a variety of models different in type of virtual light source and reflection at object surface from one another has been proposed. Typical ones of the shading models are a perfect scattered reflection model and a specular reflection model which will be described herebelow.
FIG. 2 shows a perfect scattered reflection model for shading a sphere 102.
It is assumed in the perfect scattered reflection model that a virtual light source emits parallel rays L having only directions and colors and the surface of an object is rough and has only colors, not any certain reflecting direction depending upon the position of the light source.
Assume here that the parallel rays L have colors Lr, Lg and Lb and directions Lx, Ly and Lz and that a point P on the surface of an object have colors Rt, Gt and Bt (texture information) and normals N to the point P are Nx, Ny and Nz. Then, colors of reflected rays of light from the point P on the object surface are given by the following equations (1). Note that a shift and clamp for a calculation using a fixed point are omitted.
R=Rt*Lr*(Lx*Nx+Ly*Ny+Lz*Nz)
G=Gt*Lg*(Lx*Nx+Ly*Ny+Lz*Nz)xe2x80x83xe2x80x83(1)
xe2x80x83B=Bt*Lb*(Lx*Nx+Ly*Ny+Lz*Nz)
Namely, in the perfect scattered reflection model, the reflected rays of light from a point on the surface of an object depend upon the direction and colors of rays from a light source and normals to and colors of a point on the object surface, independently of the position of a viewer.
Next, the specular reflection model will be described below.
FIG. 3 shows a specular reflection model for shading the sphere 102.
It is assumed in the specular reflection model that a virtual light source is a point source H having a position and colors and rays of light are diverged in a same manner in all directions from the source H. Also, the surface of an object is smooth like a mirror and reflected rays of light travel in directions symmetrical with respect to a normal N to a point P on the object.
Assume here that a straight line PS connecting the view point S of a viewer and the point P on the object forms an angle xcex8 with reflected rays of light OR. Then, colors of reflected rays of light from the point P on the object surface are given by the following equations (2).
R=Hr*(cos xcex8)n
G=Hg*(cos xcex8)nxe2x80x83xe2x80x83(2)
B=Hb*(cos xcex8)n
where n is a value depending upon a material of the object. Note that the larger the value n, the smoother the object surface is and the larger the light reflecting area of the object is.
Namely, in the specular reflection model, the reflection at the object surface varies depending upon a viewer""s position and is independent of colors (texture information) of a point on the object.
A combination of the aforementioned perfect scattered reflection model and specular reflection model will be described below.
FIG. 4 shows a combination of the aforementioned two types of reflection models to shade a sphere 102 with rays of light from parallel rays L and point source H.
The combination of the two types of reflection model provides an object shading more approximate to a real shading of an actual object than use of one model of reflection model, and a stereoscopic or three-dimensional vision of the object. A calculation of reflected rays of light for shading of an object using the combination of two types of reflection model is done with a following set of expressions:
R=Rt*Lr*(Lx*Nx+Ly*Ny+Lz*Nz)+Hr*(cos xcex8)n
G=Gt*Lg*(Lx*Nx+Ly*Ny+Lz*Nz)+Hg*(cos xcex8)nxe2x80x83xe2x80x83(3)
xe2x80x83B=Bt*Lb*(Lx*Nx+Ly*Ny+Lz*Nz)+Hb*(cos xcex8)n
The first term of each relation in (3) indicates a reflection by the perfect scattered reflection model, and the second term indicates a reflection by the specular reflection model.
However, a vast volume of calculation will be required for obtaining reflected rays of light for all points on an object by using the set of expressions (3). Therefore, it is impossible as a matter of fact to effect the calculation at a high speed. For solution of this problem, it has been proposed to divide the surface of an object into a plurality of small polygonal areas and effect the above-mentioned calculation with only their vertexes of the polygonal areas, thereby reducing the volume of calculation.
FIG. 5 shows how to divide a spherical surface into small triangles for the above-mentioned calculation.
As seen, colors of all pixels included in a triangle thus defined through the division of the object surface are calculated with a linear interpolation using colors calculated with three vertexes. This method is called xe2x80x9cglow shadingxe2x80x9d.
FIG. 6 shows how to calculate all colors of pixels included in each triangle on the object surface. As shown, a triangle 3a of which a color (texture information) of a point on the surface is given, and another triangle 3b of which a color change information is given, are used in a linear interpolation to provide an triangle 3c of which colors of all pixels are calculated.
Generally, such an interpolation is done by a graphic processing unit (GPU) (will be referred to as xe2x80x9cgraphic processorxe2x80x9d hereafter), and the results of the interpolative calculation are written into an image memory.
The graphic processor is a hardware which uses three vertexes of a triangle, color information of the three vertexes and texture information to effect a linear interpolation of the color information, interpolation of the texture, and a multiplication of them.
Each of the color information and texture information is generally composed of four color components R, G, B and A. The color components R, G and B are color information indicative of red, green and blue, respectively. The component A is an information used for a translucent plotting and generally called xe2x80x9calpha channelxe2x80x9d. Generally, the graphic processor comprises a color information interpolation circuit and a texture mapping circuit provided for each of the four color components R, G, B and A.
FIG. 7 shows the configuration of a conventional graphic processor.
As shown, the graphic processor comprises a texture mapping circuit 11, and a color information interpolation circuit 12. The texture mapping circuit 11 is provided to use supplied texture information Rt, Gt, Bt and At and coordinates of three vertexes of a triangle to effect a texture mapping. The color information interpolation circuit 12 uses the three-vertex color information of the triangle and the coordinates of the three vertexes to effect an interpolation of color information.
An output from the texture mapping circuit 11 and a one from the color information interpolation circuit 12 are supplied to a modulation circuit 13 and multiplied together in a multiplication circuit 13a. The result of this multiplication is an output image (Ro, Go, Bo, Ao).
It should be noted that the modulation circuit 13 makes an modulation of supplied information by addition, not by multiplication as the case may be.
The glow shading shown in FIG. 6 is one of the functions of the conventional graphic processor. For the glow shading, the conventional graphic processor multiplies a texture information by a color change information after subjected to the linear interpolation.
To modulate a texture using two kinds of color change information provided through the aforementioned perfect scattered reflection model and specular reflection model, however, the graphic processor has to include two glow shading circuits.
FIG. 8 shows how to module a texture using two kinds of color change information.
A texture information 4a from a texture mapping circuit is modulated with a first color change information 4b from a first color interpolation circuit 22a to provide a modulated texture 4c. The modulated texture 4c is further modulated with a second color change information 4d from a second color interpolation circuit 22b to provide a modulated texture 4e. To effect a calculation using the above-mentioned perfect scattered reflection model and a calculation using the specular reflection, a modulation using the first color change information is done through multiplication while a modulation using the second color change information is done through addition.
Thus, the circuit for interpolation of the color change information has to be doubled for modulation of a texture using two kinds of color change information. Also, the bus band should have an excessive width to supply the graphic processor with two kinds of color change information including one having been calculated using the specular reflection model and the other having been calculated using the specular reflection model.
FIG. 9 shows the configuration of a graphic processor adapted to module a texture using two kinds of color change information.
The graphic processor in FIG. 9 has a same configuration as shown in FIG. 7, except that it has two color information interpolation circuits.
As shown, the graphic processor comprises a texture mapping circuit 21 which uses an input texture information (Rt, Gt, Bt, At) and coordinates of three vertexes of a triangle to effect a texture mapping. It also comprises a first color information interpolation circuit 22a which uses a first three-vertex color information (Rg, Gg, Bg, Ag) obtained using the perfect scattered reflection model and the above three vertex coordinates, to effect an interpolative calculation of color information. An output from the texture mapping circuit 21 and a one from the first color information interpolation circuit 22a are multiplied together in a multiplication circuit 23a of a modulation circuit 23.
Also the graphic processor comprises a second color information interpolation circuit 22b which uses a second three-vertex color information (Rh, Gh, Bh, Ah) being three vertex coordinate color information obtained using the perfect scattered reflection model and the above three vertex coordinates, to effect an interpolative calculation of color information. An output from the second color information interpolation circuit 22b is added to an output of multiplication from the multiplication circuit 23a in an addition circuit 23b of the modulation circuit 23 to provide an output image (Ro, Go, Bo, Ao).
In the graphic processor constructed as mentioned above, the interpolation circuit for interpolation of two kinds of color change information may be doubled and the bus band width be doubled to attain a same speed of information processing as in the prior art.
Modulation of a texture using two kinds of color change information permits to attain a three-dimensional vision of an object which is approximate to a real shading but will need a larger-scale hardware including the graphic processor and an increased time for the processing.
Accordingly, it is an object of the present invention to overcome the above-mentioned drawbacks of the prior art by providing an image generating method and apparatus capable of processing image information using two kinds of color change information to generate an image having a nearly same visual effect as in the prior art without any increased scale of hardware and decreased speed of processing.
The above object can be accomplished by providing, according to the present invention, an image generating method for generating an image for display on an image display unit by pasting a texture image to each of polygonal triangular areas being component units of an image, wherein the texture information is modulated with a color change information as well as with a brightness change information.
The above object can also be accomplished by providing an image generating apparatus for generating an image for display on an image display unit by pasting a texture image to each of polygonal triangular areas being component units of an image, provided with means for effecting a texture mapping using the texture image and vertex coordinates of a polygonal area, means for interpolating color information with the vertex coordinates of the polygonal area and vertex color information, and a modulating means comprising means for multiplying the texture-mapped information and an image for which the color information is interpolated and a first means for adding a brightness information component incidental to a result of the above multiplication to the vertex color information.
The present invention provides an image generating method and apparatus capable of processing image information using two kinds of color change information to generate an image having a nearly same visual effect as in the prior art without any increased scale of hardware and decreased speed of processing.